<template>
  <div>
    <codemirror ref="codemirror" :value="sqlContent" :editorHeight="500"/>
  </div>
</template>

<script>
import codemirror from '@/components/codemirror/codemirror'

export default {
  name: "ShowSql",
  components: {codemirror},
  props: {
    sqlObject: {
      type: Object
    }
  },
  data() {
    return {
      sqlContent: null
    };
  },
  created() {
    this.initData()
  },
  methods: {
    initData() {
      if (this.sqlObject.hiveQuerySql !== undefined && this.sqlObject.hiveQuerySql !== null && this.sqlObject.hiveQuerySql !== '') {
        this.sqlContent = '--导出数据查询SQL\n' + this.sqlObject.hiveQuerySql +
          '\n--创建Hive临时文本表SQL\n' + this.sqlObject.createTxtTableSql +
          '\n--创建目标表SQL\n' + this.sqlObject.createTableSql +
          '\n--文本表数据插入到目标表SQL\n' + this.sqlObject.insertDataSql
      } else {
        this.sqlContent = ''
      }

    }
  }
};
</script>

<style scope>

</style>
